﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;

namespace Web
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //ProductTypeNavigator1.PrdtTypeList = new GoShopping.BLL.ProductTypeBean().GetAllProductTypeList();
            if (!IsPostBack)
            {
                InitialPage();
            }
            ProductTypeNavigator1.PrdtTypeList = new GoShopping.BLL.ProductTypeBean().GetAllProductTypeList();
        }

        #region Common Method
        private void ControlDisplayStyle()
        {
            dlRecoPrdtList.RepeatColumns = 3;
            dlRecoPrdtList.RepeatDirection = RepeatDirection.Horizontal;

            dlFriendlyLink.RepeatColumns = 3;
            dlFriendlyLink.RepeatDirection = RepeatDirection.Horizontal;
        }
        private static string prdtConfig = @"~/Config/PrdtConfig.xml";
        void InitialPage()
        {
            dlRecoPrdtList.DataSource = XMLManipulation.GetConfig(Server.MapPath(prdtConfig), "//Index/Recommand");
            dlRecoPrdtList.DataBind();

            dlPromotedList.DataSource = XMLManipulation.GetConfig(Server.MapPath(prdtConfig), "//Index/Promoted");
            dlPromotedList.DataBind();

            dlBrandList.DataSource = XMLManipulation.GetConfig(Server.MapPath(prdtConfig), "//Index/Brand");
            dlBrandList.DataBind();

            dlFriendlyLink.DataSource = XMLManipulation.GetConfig(Server.MapPath(prdtConfig), "//Index/FriendlyLink");
            dlFriendlyLink.DataBind();
        }
        #endregion

        #region 打折商品设置
        protected void dlPromotedList_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName == "prdtId")
            {
                Response.Redirect("CommonProducts.aspx?prdtId=" + e.CommandArgument);
            }
        }
        #endregion

        #region 推荐商品设置
        protected void dlRecoPrdtList_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName == "prdtId")
            {
                Response.Redirect("CommonProducts.aspx?prdtId=" + e.CommandArgument);
            }
        }
        #endregion

        #region 专卖店设置
        protected void dlBrandList_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName == "brand")
            {
                Response.Redirect("PrdtListByBrand.aspx?prdtBrand=" + e.CommandArgument);
            }
        }
        #endregion

        #region 友情链接设置
        protected void dlFriendlyLink_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName == "friendId")
            {
                Response.Redirect("CommonProducts.aspx?prdtId=" + e.CommandArgument);
            }
        }
        #endregion

        #region 主商品设置

        #endregion
    }
}